package com.qcby.config;


import com.qcby.interceptor.AdminInterceptor;
import com.qcby.interceptor.StudentInterceptor;
import com.qcby.interceptor.TeacherInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SessionConfig implements WebMvcConfigurer {
    @Autowired
    private AdminInterceptor AdminInterceptor;
    @Autowired
    private TeacherInterceptor TeacherInterceptor;
    @Autowired
    private StudentInterceptor StudentInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(AdminInterceptor)
                .addPathPatterns("/a/**")
                .excludePathPatterns("/admin/login/**")
                .excludePathPatterns("/a/AdminLogin/**");
        registry.addInterceptor(TeacherInterceptor)
                .addPathPatterns("/t/**")
                .excludePathPatterns("/teacher/login/**")
                .excludePathPatterns("/teacher/msglist/**")
                .excludePathPatterns("/t/TeacherLogin/**");
        registry.addInterceptor(StudentInterceptor)
                .addPathPatterns("/s/**")
                .excludePathPatterns("/student/login/**")
                .excludePathPatterns("/s/StudentLogin/**");
    }
}
